import { createSlice } from "@reduxjs/toolkit";
let initialState = {
  email: "",
  username: "",
  password: "",
  errors: null,
};

export const registSlice = createSlice({
  name: "regist",
  initialState,
  reducers: {
    registFileUpdate(state, action) {
      const { key, value } = action.payload;
      state[key] = value;
    },
    registSubmit(state, action) {
      state.errors = action.payload;
    },
    onUnload() {
      return { ...initialState };
    },
  },
});

export const { registFileUpdate, registSubmit, onUnload } = registSlice.actions;

export default registSlice.reducer;
